package com.my.common;

import javax.servlet.http.HttpServletRequest;

import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import com.my.constant.Common;
import com.my.entity.Employee;
import com.my.service.EmployeeService;


public class ManagerTaskHandler  implements TaskListener {
	private static final long serialVersionUID = 1L;
	private static final Logger logger = LoggerFactory.getLogger(ManagerTaskHandler.class);

	/**
	 * 安排下一个人的任务
	 */
	public void notify(DelegateTask delegateTask) {
		HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
		Employee employee = (Employee) request.getSession().getAttribute(Common.CURRENT_OPERATOR.getValue());
		String name = employee.getName();
		EmployeeService employeeService =(EmployeeService) IApplicationContext.getBean("employeeService");
		Employee emp = employeeService.queryManagerEmployeeName(name);
		delegateTask.setAssignee(emp.getName());
	}


}
